﻿using Core.Proxy.Attributes.InterceptorAttributes.BaseAttributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.Proxy.Attributes.InterceptorAttributes
{
    /// <summary>
    /// 标记此特性代表缓存当前方法的执行结果,当下次执行方法命中缓存后,直接返回缓存结果,而不会执行代码逻辑
    /// </summary>
    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
    public class ReturnValueCacheAttribute : BaseCacheAttribute
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="expireMillisecond">缓存时间</param>
        /// <param name="constKey">常量缓存key</param>
        /// <param name="dynamicParamKey">动态key</param>
        public ReturnValueCacheAttribute(int expireMillisecond, string constKey, string dynamicParamKeys = null)
        {
            ExpireMillisecond = expireMillisecond;
            ConstKey = constKey;
            if (!string.IsNullOrEmpty(dynamicParamKeys))
            {
                DynamicParamKeys = dynamicParamKeys.Split(",").ToList();
            }

        }
    }
}
